import java.text.SimpleDateFormat

/**
 * 用于显示日期的自定义标签
 * @author Tony Shen
 */
class DateTagLib {
  def customDateFormat = {attrs, body ->
    def b = attrs.body ?: body()
    def d = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(b)

    //if no format attribute is supplied, use this
    def pattern = attrs["format"] ?: "yyyy/MM/dd"
    out << new SimpleDateFormat(pattern).format(d)
  }

}
